package org.feidao.chapter64.producer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;
import java.util.UUID;
/**
 * Created by linghufeixia on 2022-12-28.
 * header service
 */
@Slf4j
@Service
public class HeadersService {
    String exchange = "headers_exchange";
    String routeKey = "";

    @Resource
    private RabbitTemplate rabbitTemplate;

    public void sendData(String data) {
        log.info("------------headers producer begin------------");
        MessageProperties messageProperties = new MessageProperties();
        messageProperties.setHeader("type", "gass");
        messageProperties.setHeader("data", "realTime");
        //messageProperties.setHeader("data", "history");
        Message message = new Message(data.getBytes(), messageProperties);
        rabbitTemplate.convertAndSend(exchange, routeKey, message);
        log.info("send data:"+data);
        log.info("------------headers producer end------------");
    }

}
